import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

/**
 * @ClassName LC414
 * @Author ykx
 * @Date 2024/6/29 16:28
 * @Version 1.0
 */
public class LC414 {
    public static void main(String[] args) {
        LC414 lc414 = new LC414();
        System.out.println(lc414.thirdMax(new int[]{3, 2, 1}));
    }

    public int thirdMax(int[] nums) {
        Set<Integer> set = new TreeSet<>(Comparator.reverseOrder());
        for (int num : nums) {
            set.add(num);
        }

        int[] arr = new int[set.size()];
        int index = 0;
        for (Integer e : set) {
            arr[index++] = e;
        }

        return arr[set.size() >= 3 ? 2 : 0];

    }

}
